<?php

//power by wshoto.com
if (!defined('IN_IA')) {
	die('Access Denied');
}

global $_W, $_GPC;

$openid = m('user')->getOpenid();

if(!empty($openid)){
	// 获取商店/交易设置
	$set = m('common')->getSysset(array('shop', 'trade'));

	// 当前用户信息
	$member = m('member')->getMember($openid, true);
	$member['credit1'] = number_format($member['credit1'], 0);
	$member['credit2'] = number_format($member['credit2'], 2);

	$superior = array();
	// 上级用户
	if(!empty($member['agentid'])){
		$superior = m('member')->getMember($member['agentid']);
	}

	// 分销插件实例化
	$commissionPlugin = p('commission');

	// 分销相关设置
	$commissionSet = $commissionPlugin->getSet();

	// 会员分销商等级
	$member['commission'] = $commissionPlugin->getLevel($member['openid']);

	if(empty($member['commission'])){
		$member['commission']['levelname'] = $commissionSet['levelname'];
	}

	// 我的团队
	$teamLists = $commissionPlugin->getCommissionTeamCount($openid);
	// 我的分销订单
	$orderStatistics = $commissionPlugin->getCommissionRecordStatistics($openid, array( 'o_status_0', 'o_status_1', 'o_status_2', 'o_status_3' ));

	// 我的佣金：TOTAL = 总额， OK = 可提现， LOCK = 不可提现， APPLY = 正在申请， PAY = 已支付  UNFINISH = 未完成
	$recordPrice = $commissionPlugin->getCommissionRecordPrice($openid, array( 'unfinish', 'total', 'pay', 'ok', 'lock', 'apply', 'check', 'invalid' ));
}

include $this->template('member/center');